﻿using System;
using Stylet;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using PropertyChanged;
using System.ComponentModel;
using System.Windows.Data;

namespace WpfApplication1.Pages
{
    public class ShellViewModel : Screen, INotifyPropertyChanged
    {
        private ObservableCollection<ChatMessage> m_Messages = new ObservableCollection<ChatMessage>();
        public ObservableCollection<ChatMessage> Messages { get { return m_Messages; } }
        public ShellViewModel()
        {
            Messages.Add(new ChatMessage() { IsSend = false, Message = "恭喜！你被录用了" });
            Messages.Add(new ChatMessage() { IsSend = false, Message = "明天来总部上班" });
            Messages.Add(new ChatMessage() { IsSend = true, Message = "OK" });
        }

        public int SelectedMessage { get; set; }
        public string Message { get; set; }

        public bool CanSendMessage
        {
            get { return !string.IsNullOrEmpty(Message); }
        }
        public void SendMessage()
        {
            m_Messages.Add(new ChatMessage() { IsSend = true, Message = Message });
            m_Messages.Add(new ChatMessage() { IsSend = false, Message = Message });

            SelectedMessage = m_Messages.Count - 1;

            //CollectionViewSource.GetDefaultView(m_Messages).MoveCurrentTo(m_Messages[m_Messages.Count - 1]);
        }
    }
}
